package com.leyou.item.web;


import com.leyou.item.dto.CategoryLevelDto;
import com.leyou.item.pojo.Category;
import com.leyou.item.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author:yanjizhw@163.com
 * @date:2019-09-23 14:47
 * 描述:
 * @since:1.0.0
 */
@RestController
@RequestMapping("category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    /**
     * 根据父节点 id 查询商品分类
     * @return
     */
    @GetMapping("list")
    public ResponseEntity<List<Category>> queryCategoryByPid(){

        return ResponseEntity.ok(categoryService.queryCategoryList());
    }


    @GetMapping("tree")
    public ResponseEntity<List<CategoryLevelDto>> queryCategoryTree(){

        return ResponseEntity.ok(categoryService.queryCategoryTree());
    }
}
